home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vb_ap21 / vbapi.frm < prev    next >
Text File  |  1995-09-06  |  6KB  |  194 lines

  1. VERSION 2.00
  2. Begin Form VBAPI 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "VB API Help"
  6.    ClientHeight    =   330
  7.    ClientLeft      =   2715
  8.    ClientTop       =   2385
  9.    ClientWidth     =   1560
  10.    ControlBox      =   0   'False
  11.    Height          =   735
  12.    Icon            =   VBAPI.FRX:0000
  13.    Left            =   2655
  14.    LinkTopic       =   "Form1"
  15.    MaxButton       =   0   'False
  16.    MinButton       =   0   'False
  17.    ScaleHeight     =   330
  18.    ScaleWidth      =   1560
  19.    Top             =   2040
  20.    Width           =   1680
  21. End
  22. DefInt A-Z
  23. Const TRUE = -1, FALSE = 0
  24. Const HELP_QUIT = 2
  25. Const HELP_INDEX = 3
  26. Const LEFT_BUTTON = 1
  27. Const RIGHT_BUTTON = 2
  28. Const SHIFT_MASK = 1
  29. Const CTRL_MASK = 2
  30. Const GCW_HMODULE = (-16)
  31. Dim XOff, YOff, Hold
  32. Dim Mouse As POINTAPI
  33. Declare Function WinHelp Lib "User" (ByVal hWnd As Integer, ByVal lpHelpFile As String, ByVal wCommand As Integer, dwData As Any) As Integer
  34. Declare Function GetModuleFileName Lib "Kernel" (ByVal hModule As Integer, ByVal lpFileName As String, ByVal nSize As Integer) As Integer
  35. Declare Function GetClassWord Lib "User" (ByVal hWnd As Integer, ByVal nIndex As Integer) As Integer
  36. Declare Function GetPrivateProfileInt Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Integer, ByVal lpFileName As String) As Integer
  37. Declare Function WritePrivateProfileString Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As Any, ByVal lplFileName As String) As Integer
  38. Declare Function SetCapture Lib "User" (ByVal hWnd As Integer) As Integer
  39. Declare Sub ReleaseCapture Lib "User" ()
  40. Declare Sub GetCursorPos Lib "User" (lpPoint As POINTAPI)
  41.  
  42. Sub Form_Load ()
  43.   Select Case WindowState
  44.     Case 0
  45.       Caption = ""
  46.     Case 1
  47.       Caption = "VB API Help"
  48.   End Select
  49.   PutWindow
  50.   VBAPI.Refresh
  51. End Sub
  52.  
  53. Sub Form_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  54.   RButt = (Button And RIGHT_BUTTON) > 0
  55.   If RButt Then
  56.     Z = SetCapture(VBAPI.hWnd)
  57.     GetCursorPos Mouse
  58.     XOff = (Mouse.X * 15) - VBAPI.Left
  59.     YOff = (Mouse.Y * 15) - VBAPI.Top
  60.     MousePointer = 5
  61.   End If
  62. End Sub
  63.  
  64. Sub Form_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
  65.   RButt = (Button And RIGHT_BUTTON) > 0
  66.   If RButt Then
  67.     GetCursorPos Mouse
  68.     XPo = Signed%((Mouse.X * 15) - XOff)
  69.     YPo = Signed%((Mouse.Y * 15) - YOff)
  70.     Move XPo, YPo
  71.   End If
  72. End Sub
  73.  
  74. Sub Form_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
  75.   RButt = (Button And RIGHT_BUTTON) > 0
  76.   LButt = (Button And LEFT_BUTTON) > 0
  77.   Ctrl = (Shift And CTRL_MASK) > 0
  78.   Shft = (Shift And SHIFT_MASK) > 0
  79.   If RButt Then
  80.     GetCursorPos Mouse
  81.     XPo = Signed%((Mouse.X * 15) - XOff)
  82.     YPo = Signed%((Mouse.Y * 15) - YOff)
  83.     Move XPo, YPo
  84.     MousePointer = 0
  85.     ReleaseCapture
  86.   ElseIf Ctrl And LButt Then
  87.     Unload VBAPI
  88.   ElseIf Shft And LButt Then
  89.     SavePosition
  90.     WindowState = 1
  91.   ElseIf LButt Then
  92.     GetHelp HELP_INDEX
  93.   End If
  94. End Sub
  95.  
  96. Sub Form_Paint ()
  97.   Tp = ScaleTop
  98.   Lf = ScaleLeft + 7
  99.   Bt = ScaleHeight - 8
  100.   Rt = ScaleWidth - 15
  101.   Line (Lf, Bt)-(Rt, Bt), &H808080
  102.   Line (Rt, Tp)-(Rt, Bt), &H808080
  103.   Line (Lf + 15, Tp + 15)-(Rt - 15, Tp + 15), &HFFFFFF
  104.   Line (Lf + 15, Tp + 15)-(Lf + 15, Bt - 15), &HFFFFFF
  105.   Line (Lf + 15, Bt - 15)-(Rt - 15, Bt - 15), &H808080
  106.   Line (Rt - 15, Tp + 15)-(Rt - 15, Bt - 15), &H808080
  107.   Lab$ = "VB API Help"
  108.   X = (Width - TextWidth(Lab$)) \ 2
  109.   Y = (Height - TextHeight(Lab$)) \ 2
  110.   Col& = ForeColor
  111.   ForeColor = &HFFFFFF
  112.   CurrentY = Y + 15
  113.   CurrentX = X + 15
  114.   Print Lab$;
  115.   ForeColor = Col&
  116.   CurrentY = Y
  117.   CurrentX = X
  118.   Print Lab$;
  119. End Sub
  120.  
  121. Sub Form_Resize ()
  122.   Select Case WindowState
  123.     Case 0
  124.       If Hold Then Exit Sub
  125.       If VBAPI.Caption <> "" Then VBAPI.Caption = ""
  126.       PutWindow
  127.       VBAPI.Refresh
  128.     Case 1
  129.       VBAPI.Caption = "VBAPI Help"
  130.   End Select
  131. End Sub
  132.  
  133. Sub Form_Unload (Cancel As Integer)
  134.   GetHelp HELP_QUIT
  135.   SavePosition
  136. End Sub
  137.  
  138. Sub GetHelp (HlpType)
  139.   Hlp$ = LTrim$(RTrim$(HomePath$())) + "vbapi.hlp"
  140.   Select Case HlpType
  141.     Case HELP_INDEX
  142.       X = WinHelp(VBAPI.hWnd, Hlp$, HELP_INDEX, ByVal 0&)
  143.       If X = False Then
  144.     NL$ = Chr$(13) + Chr$(10)
  145.     Msg$ = "Unable to access help file." + NL$ + NL$
  146.     Msg$ = Msg$ + "Please make sure the help" + NL$
  147.     Msg$ = Msg$ + "file (VBAPI.HLP) is in" + NL$
  148.     Msg$ = Msg$ + "the same directory as the" + NL$
  149.     Msg$ = Msg$ + "executable (VBAPI.EXE)."
  150.     Tit$ = "VB API Help"
  151.     MsgBox Msg$, 48, Tit$
  152.       End If
  153.     Case HELP_QUIT
  154.       Y = WinHelp(VBAPI.hWnd, "", HELP_QUIT, ByVal 0&)
  155.   End Select
  156. End Sub
  157.  
  158. Function HomePath$ ()
  159.   Hlp$ = String$(255, 0)
  160.   hMod = GetClassWord(VBAPI.hWnd, GCW_HMODULE)
  161.   FLn& = GetModuleFileName(hMod, Hlp$, 255)
  162.   Hlp$ = Left$(LTrim$(RTrim$(Hlp$)), FLn& - 9)
  163.   HomePath$ = Hlp$
  164.   Hlp$ = ""
  165. End Function
  166.  
  167. Sub PutWindow ()
  168.   Hold = True
  169.   Pf$ = LTrim$(RTrim$(HomePath$())) + "vbapi.ini"
  170.   Lf = Screen.Width - 1410
  171.   Tp = Screen.Height - 330
  172.   L = GetPrivateProfileInt("Position", "Left", Lf, Pf$)
  173.   T = GetPrivateProfileInt("Position", "Top", Tp, Pf$)
  174.   If L > Lf Then L = Lf
  175.   If T > Tp Then T = Tp
  176.   Move L, T, 1410, 330
  177.   Hold = False
  178. End Sub
  179.  
  180. Sub SavePosition ()
  181.   Fl$ = LTrim$(RTrim$(HomePath$())) + "vbapi.ini"
  182.   Uh = WritePrivateProfileString("Position", "Top", LTrim$(RTrim$(Str$(VBAPI.Top))), Fl$)
  183.   Uh = WritePrivateProfileString("Position", "Left", LTrim$(RTrim$(Str$(VBAPI.Left))), Fl$)
  184. End Sub
  185.  
  186. Static Function Signed% (XNum&)
  187.     If XNum& > 32767 Then
  188.        Signed% = XNum& - 65536
  189.     Else
  190.        Signed% = XNum&
  191.     End If
  192. End Function
  193.  
  194.